#include "stdafx.h"
#include "Gorilla.h"

enum mMenuEnum {START,OPTIONS,QUIT};
enum menusEnum {MAINM,STARTM,OPTIONSM,QUITM,TOSM,FRSM,TOOM,FROM,TOQM,FRQM};
enum oMenuEnum {RES,RAY,HDR,VSYNC};

struct mMenuLoop
{
struct mMenuLoop* nextState;
struct mMenuLoop* prevState;
mMenuEnum mState;
};

struct oMenuLoop
{
struct oMenuLoop* nextState;
struct oMenuLoop* prevState;
oMenuEnum mState;
};

struct buttonLoop
{
struct buttonLoop* nextState;
struct buttonLoop* prevState;
Gorilla::Caption* mButton;
};

struct resLoop
{
struct resLoop* nextRes;
struct resLoop* prevRes;
std::string* res;
};

struct GameConfig
{
int width;
int height;
bool godRay;
bool hdr;
bool vsync;
};


class mainMenu
{
public:

	mainMenu(Ogre::SceneManager * sceneMgr, Ogre::Camera* mCam,Ogre::RenderWindow* mWin,Ogre::RenderSystem* rs);  
	~mainMenu () {}
	void setMainMenu();
	void showOptions();
	void closeOptions();
	void updateFPS(Ogre::Real value);
	void saveCfg();
	void updateMenu(Ogre::Real evt,bool rebuildMesh);
	int mainMenuPressed();
	int pressedKey(const OIS::KeyEvent &arg);
	void mouseMoveUpdate(int x,int y);

private:
	mMenuLoop* mMenuState;
	menusEnum currentMenu;
	oMenuLoop* oMenuState;
	resLoop* resolutionsLoop;
	buttonLoop* cOptionButton;
	buttonLoop* cOptionButtonA;
	buttonLoop* firstOptionButton;
	buttonLoop* firstOptionButtonA;
	int menuMovingDir;
	bool moving;
	Ogre::StringVector mFoundResolutions;
	Ogre::Real atm;
	Ogre::SceneManager * mSceneMgr;
	Ogre::Camera* mCamera;
	Ogre::RenderWindow* mWindow;
	std::vector<Gorilla::Caption*> mMenuButtons;
	std::vector<Gorilla::Caption*> oMenuButtons;
	Gorilla::Silverback*    mSilverback;
  Gorilla::Screen*        mScreen;
  Gorilla::Layer*         mLayer, *mouseLayer;
  Gorilla::Caption*       fpsCaption;
  Gorilla::Caption*       debugCaption;
  Gorilla::Rectangle*      mousePointer;
  struct GameConfig* gConfig;
};